﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace C556Backside.Migrations
{
    /// <inheritdoc />
    public partial class init : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "ActivityTypeModels",
                columns: table => new
                {
                    ActivityTypeID = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    ActivityTypeName = table.Column<string>(type: "nvarchar(max)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ActivityTypeModels", x => x.ActivityTypeID);
                });

            migrationBuilder.CreateTable(
                name: "Managers",
                columns: table => new
                {
                    ManagerID = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Managers", x => x.ManagerID);
                });

            migrationBuilder.CreateTable(
                name: "Organizations",
                columns: table => new
                {
                    OrganizationID = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    OrganizationTelephone = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    OrganizationName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    OrganizationPassword = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Province = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    City = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Area = table.Column<string>(type: "nvarchar(max)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Organizations", x => x.OrganizationID);
                });

            migrationBuilder.CreateTable(
                name: "Voluntary",
                columns: table => new
                {
                    VoluntaryID = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    VoluntaryTelephone = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    VoluntaryName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    VoluntaryPassword = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Province = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    City = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Area = table.Column<string>(type: "nvarchar(max)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Voluntary", x => x.VoluntaryID);
                });

            migrationBuilder.CreateTable(
                name: "VoluntaryActivities",
                columns: table => new
                {
                    ActivityID = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    ActivityName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ActivityTypeID = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    ActivityCreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    ActivityCompleteTime = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ActivityComplete = table.Column<bool>(type: "bit", nullable: false),
                    VoluntaryContent = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    OrganizationID = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    Province = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    City = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Area = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    DetailedAddress = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_VoluntaryActivities", x => x.ActivityID);
                    table.ForeignKey(
                        name: "FK_VoluntaryActivities_ActivityTypeModels_ActivityTypeID",
                        column: x => x.ActivityTypeID,
                        principalTable: "ActivityTypeModels",
                        principalColumn: "ActivityTypeID",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_VoluntaryActivities_Organizations_OrganizationID",
                        column: x => x.OrganizationID,
                        principalTable: "Organizations",
                        principalColumn: "OrganizationID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "VAVRelationshipsTable",
                columns: table => new
                {
                    RelationID = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    VoluntaryID = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    JoinTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    ActivityID = table.Column<string>(type: "nvarchar(450)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_VAVRelationshipsTable", x => x.RelationID);
                    table.ForeignKey(
                        name: "FK_VAVRelationshipsTable_VoluntaryActivities_ActivityID",
                        column: x => x.ActivityID,
                        principalTable: "VoluntaryActivities",
                        principalColumn: "ActivityID",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_VAVRelationshipsTable_Voluntary_VoluntaryID",
                        column: x => x.VoluntaryID,
                        principalTable: "Voluntary",
                        principalColumn: "VoluntaryID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "ActivityReviews",
                columns: table => new
                {
                    ReviewID = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    VAAndVID = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    ReviewContent = table.Column<string>(type: "nvarchar(max)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ActivityReviews", x => x.ReviewID);
                    table.ForeignKey(
                        name: "FK_ActivityReviews_VAVRelationshipsTable_VAAndVID",
                        column: x => x.VAAndVID,
                        principalTable: "VAVRelationshipsTable",
                        principalColumn: "RelationID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.InsertData(
                table: "Managers",
                columns: new[] { "ManagerID", "Name", "Password" },
                values: new object[] { "0b129cc5-5260-4e08-a1c0-b356152177cd", "Test1", "6666666" });

            migrationBuilder.InsertData(
                table: "Organizations",
                columns: new[] { "OrganizationID", "Area", "City", "OrganizationName", "OrganizationPassword", "OrganizationTelephone", "Province" },
                values: new object[] { "660c6878-1bda-4572-9eb5-ecf538f095c9", "顺德区", "佛山市", "Test1", "666666", "135382223769", "广东省" });

            migrationBuilder.InsertData(
                table: "Voluntary",
                columns: new[] { "VoluntaryID", "Area", "City", "Province", "VoluntaryName", "VoluntaryPassword", "VoluntaryTelephone" },
                values: new object[] { "bce85775-2f9c-4066-b2f4-555ced8a505c", "长清区", "济南市", "山东省", "Test1", "666666", "15007473346" });

            migrationBuilder.CreateIndex(
                name: "IX_ActivityReviews_VAAndVID",
                table: "ActivityReviews",
                column: "VAAndVID");

            migrationBuilder.CreateIndex(
                name: "IX_VAVRelationshipsTable_ActivityID",
                table: "VAVRelationshipsTable",
                column: "ActivityID");

            migrationBuilder.CreateIndex(
                name: "IX_VAVRelationshipsTable_VoluntaryID",
                table: "VAVRelationshipsTable",
                column: "VoluntaryID");

            migrationBuilder.CreateIndex(
                name: "IX_VoluntaryActivities_ActivityTypeID",
                table: "VoluntaryActivities",
                column: "ActivityTypeID");

            migrationBuilder.CreateIndex(
                name: "IX_VoluntaryActivities_OrganizationID",
                table: "VoluntaryActivities",
                column: "OrganizationID");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "ActivityReviews");

            migrationBuilder.DropTable(
                name: "Managers");

            migrationBuilder.DropTable(
                name: "VAVRelationshipsTable");

            migrationBuilder.DropTable(
                name: "VoluntaryActivities");

            migrationBuilder.DropTable(
                name: "Voluntary");

            migrationBuilder.DropTable(
                name: "ActivityTypeModels");

            migrationBuilder.DropTable(
                name: "Organizations");
        }
    }
}
